#include "Core/GlPlatform.h"

#define HEAD_RADIUS		1.15
#define numOfStars		100000

GLUquadricObj *quad;
//<<<<<<<<<<<<<<<<<<<<<<< myDisplay >>>>>>>>>>>>>>>>>>>>>>>>>>
void drawSpaceScene()
{
	GLfloat mat_specular[] = {1.0, 1.0, 1.0, 1.0};
	GLfloat mat_diffuse[] = {1.0, 1.0, 1.0, 1.0};
	GLfloat mat_ambient[] = {1.0, 1.0, 1.0, 1.0};
	GLfloat mat_shininess = {100.0};
	GLfloat light_ambient[] = {0.0, 0.0, 0.0, 1.0};
	GLfloat light_diffuse[] = {0.858824, 0.858824, 0.439216, 1.0};
	GLfloat light_specular[] = {1.0, 1.0, 1.0, 1.0};
	GLfloat light_position[] = {10.0, 10.0, 10.0, 0.0};

	glLightfv(GL_LIGHT0, GL_POSITION, light_position);
	glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient);
	glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse);
	glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular);

	glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
	glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient);
	glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse);
	glMaterialf(GL_FRONT, GL_SHININESS, mat_shininess);

	glShadeModel(GL_SMOOTH);
	glEnable(GL_LIGHTING); 
	glEnable(GL_LIGHT0);
	glDepthFunc(GL_LEQUAL);
	glEnable(GL_DEPTH_TEST);
	glEnable(GL_NORMALIZE);
	glEnable(GL_COLOR_MATERIAL);

	glColor3f(1.0,1.0,1.0);
	
	glPushMatrix();
	glScalef( 50, 50, 50 );
		quad = gluNewQuadric();
		gluQuadricDrawStyle(quad, GLU_FILL);
		gluQuadricOrientation(quad, GLU_OUTSIDE);


		glTranslatef(-7.0, 0.0, -25.0);
		glColor3f(0.858824, 0.858824, 0.439216);
		gluSphere(quad, 10.377648, 20, 20);	 //sun
		glTranslatef(12.0, 0.0, 0.0);
		glColor3f(0.647059,0.164706,0.164706);
		gluSphere(quad, 0.04880, 20, 20);	//merc
		glTranslatef(1.0, 0.0, 0.0);
		glColor3f(0.329412,0.329412,0.329412);
		gluSphere(quad, 0.12104, 20, 20);	   //venus
		glTranslatef(1.0, 0.0, 0.0);
		glColor3f(0.196078,0.6,0.8);
		gluSphere(quad, 0.12756, 20, 20);	   //earth
		glTranslatef(0.25, 0.0, 0.0);
		glColor3f(0.658824,0.658824,0.658824);
		gluSphere(quad, 0.03476, 20, 20);	   // moon
		glTranslatef(1.0, 0.0, 0.0);
		glColor3f(1.0,0.184314,0.284314);
		gluSphere(quad, 0.06788, 20, 20);	   // mars
		glTranslatef(2.5, 0.0, 0.0);
		glColor3f(1.0,0.498039,0.0);
		gluSphere(quad, 1.4274, 20, 20);	   // jupiter
		glTranslatef(4.5, 0.0, 0.0);
		glColor3f(0.96,0.80,0.69);
		gluSphere(quad, 1.20034, 20, 20);	   // saturn
		glRotatef(-75.0, 1.0, 0.0, 0.0);
		gluDisk(quad, 1.3, 1.5, 20, 20);
		gluDisk(quad, 1.55, 1.9, 20, 20);
		gluDisk(quad, 1.95, 2.05, 20, 20);
		gluDisk(quad, 2.1, 2.4, 20, 20);
		glRotatef(75.0, 1.0, 0.0, 0.0);
		glTranslatef(4.0, 0.0, 0.0);
		glColor3f(0.258824,0.258824,0.435294);
		gluSphere(quad, 0.51152, 20, 20);	   // uranus
		glTranslatef(2.0, 0.0, 0.0);
		glColor3f(0.137255,0.419608,0.556863);
		gluSphere(quad, 0.49620, 20, 20);	   // neptune
		glTranslatef(2.5, 0.0, 0.0);
		glColor3f(0.137255,0.419608,0.556863);
		gluSphere(quad, 0.02296, 20, 20);	   // pluto	

		glTranslatef(-12, 0.0, 0.0);

		for(int x = -20; x < 20; x++)
	{
		glBegin(GL_LINES);

		// 'ground' grid
		glColor3f(0.5, 1.0, 0.0);	 
			glVertex3d(x, -4, 20);
			glVertex3d(x, -4, -20);
			glVertex3d(20, -4, x);
			glVertex3d(-20, -4, x);
			glVertex3d(x+.5, -4, 20);
			glVertex3d(x+.5, -4, -20);
			glVertex3d(20, -4, x+.5);
			glVertex3d(-20, -4, x+.5);

		// 'sky' grid
		glColor3f(0.0, 1.0, 1.0);
			glVertex3d(x, 5, 20);
			glVertex3d(x, 5, -20);
			glVertex3d(20, 5, x);
			glVertex3d(-20, 5, x);
			glVertex3d(x+.5, 5, 20);
			glVertex3d(x+.5, 5, -20);
			glVertex3d(20, 5, x+.5);
			glVertex3d(-20, 5, x+.5);
		glEnd();
	}

	glPopMatrix();
} 